Release 10.1A: OpenEdge Data Management:
SQL Reference


FETCH

Moves the position of the cursor to the next row of the active set and fetches the column values of the current row into the specified host variables.

Syntax

FETCH cursor_name 
  { USING SQL DESCRIPTOR structure_name 
    | INTO :host_var_ref [ [ INDICATOR ] :ind_var_ref ] , ... 
  } ; 

cursor_name

A name identified in an earlier DECLARE CURSOR statement and an OPEN CURSOR statement.

USING SQL DESCRIPTOR structure_name

Directs the SQL engine to FETCH data into storage addressed by an SQLDA structure.

INTO :host_var_ref [ [ INDICATOR ] :ind_var_ref ]

Directs the SQL engine to FETCH data into the identified host variables, and to set values in the identified indicator variables.

Example

/* 
**  One way to limit the number of rows returned is to 
**  set a new value for "j" here. As supplied in the SPORTS2000 database, 
**  the PUB.InventoryTrans table contains 75 rows. 
*/  
      j = 100; 
      for (i = 0; i < j; i++) 
           {  
           EXEC SQL FETCH dyncur INTO 
             :int_p1_v, :int_p2_v, :char_p_v ; 
           if (i == 0) 
               { 
               printf (" 1st col  2nd col  3rd col"); 
               printf (" -------  -------  --------"); 
               }   
           printf (" %d  %d  %s ",  
                   int_p1_v, int_p2_v, char_p_v) ;  
           } 

Notes

Authorization

None

Related statements

DECLARE CURSOR, OPEN, CLOSE


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095